library(BiocManager)
library(DESeq2)
setwd("D://文件//1")
data1<-read.csv("D://文件//1//mRNA_exprSet.csv")
data1<-data1[,2:ncol(data1)]
data1<-data1[rowMeans(data1)>1,]
colnames(data1)<-substr(colnames(data1), nchar(colnames(data1)) - 1, nchar(colnames(data1)))
col<-data.frame(colnames(data1))
col[,1] <- as.factor(col$colnames.data1.)
dds <-  DESeqDataSetFromMatrix(countData =data1,colData = col,design = ~colnames.data1.)
dim(dds)
dds <- dds[rowSums(counts(dds)) > 1,]
nrow(dds) 
dep <- DESeq(dds)
res <- results(dep)
res
diff = res
diff <- na.omit(diff)  ## 去除缺失值NA
dim(diff)
diff
###进一步筛选差异表达基因

foldChange = 1
padj = 0.05/19630
diffsig <- diff[(diff$pvalue < padj & abs(diff$log2FoldChange) > foldChange),]
diffsig
diffsig$sig <- ifelse(diffsig$log2FoldChange > 1, "up", "down")
diffsig
